package com.itheima.mapper.system;

import com.itheima.domain.system.Permission;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface PermissionMapper {

    @Select("select * from permission order by create_time")
    List<Permission> findAll();

    @Insert("insert into permission values(#{id},#{permissionName},#{url},#{createTime})")
    void save(Permission permission);

    @Select("select * from permission where id=#{id}")
    Permission findById(String id);

    @Delete("delete from permission where id =#{deleteId}")
    void delete(String deleteId);

    @Delete("delete from role_permission where permissionId =#{deleteId}")
    void deletePermRoleByPid(String id);

    @Select("select * from permission where id in(select permissionId from role_permission where RoleId=#{rid})")
    List<Permission> findPermsByRid(String rid);
}
